<?php
require_once 'BaseController.php';

/**
 * 【SP版】駅変更 コントローラ
 */
class Mobileapi_EkiChangeController extends Mobileapi_BaseController
{

    /**
     * メインアクション(post)
     */
    public function postAction()
    {
        $params = $this->getParameters();
        $area = substr($params['target_0'], 0, 2);
        $rail = array();
        foreach ($params as $key => $val)
        {
            if (strpos($key, 'target') !== false)
            {
                $rail[] = substr($val, 3, 4);
            }
        }
        $this->makeTemplateParams1($area, $rail);
        $this->_data['Mapping_params'] = $params;
        $this->displayBody2('index');
    }

    private function makeTemplateParams1($area_code, $rail)
    {
        $model = new Search_Model_Seleki();
        $params = array();
        $params['PrefCd'][] = $area_code;
        $params['RailCd'] = array();
        $params['RailCd'] = $rail;

        $data = array();
        $data["seleki"] = $model->getEkiData($params);
        $model->convertEkiData($data);

        $this->_data['Mapping'] = $data["Mapping"];
    }

}
?>